<template>
	<view class="detail-container" v-if="isLoadEnd">
		<view class="content">
			<view class="name">
				姓名：<text>{{list.name}}</text>
			</view>
			<view class="age">
				年龄：<text>{{list.age}}</text>
			</view>
			<view class="sex">
				性别：<text>{{list.sex===0?"男":"女"}}</text>
			</view>
			<view class="email">
				邮箱：<text>{{list.email}}</text>
			</view>
			<view class="phone" @click="callphone">
				联系电话：<text>{{list.phone}}</text>(点击即可拨打联系)
			</view>
			<view class="hobby">
				兴趣爱好：<text>{{list.hobby}}</text>
			</view>
			<view class="introduction">
				自我介绍：<text>{{list.introduction}}</text>
			</view>
			<view class="introduction">
				工作时间：<text>{{list.workTime[0] | formatDate}}</text>----<text>{{list.workTime[1] | formatDate}}</text>
			</view>
		</view>
		<view class="btn" v-if="list.status===0">
			<button class="agree" @click="handleForm(2)">同意</button>
			<button class="reject" @click="handleForm(1)">拒绝</button>
		</view>
		<view class="btn" v-if="list.status === 1">
			<button>已拒绝</button>
		</view>
		<view class="btn" v-if="list.status === 2">
			<button>已同意</button>
		</view>
	</view>
</template>

<script>
	import {updateEnrollInfo} from '../../../ajax/api/qiye.js';
	export default {
		data() {
			return {
				list: [],
				isLoadEnd: false
			}
		},
		onShow() {
			this.list = this.$Route.query.item;
			this.isLoadEnd = true;
			console.log(this.list)
		},
		filters: {
			// 时间戳格式化时间
			formatDate(value) {
				if (value == undefined) {
					return;
				}
				// let date = new Date(value * 1000);
				let date = new Date(value);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				return y + '-' + MM + '-' + d; //年月日
			}
		},
		methods: {
			callphone(){
				wx.makePhoneCall({
					phoneNumber:this.list.phone
				})
			},
			// 处理报名表
			async handleForm(e){
				const res =	await updateEnrollInfo(this.list._id,{status:e});
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
.detail-container{
	padding:40rpx;
	.content{
		view{
			height: 80rpx;
		}
	}
	.btn{
		margin-top: 60rpx;
		display: flex;
		button{
			background: $base-color;
			color: #fff;
		}
	}
}
</style>
